package com.example.bigevent.config;

import com.example.bigevent.Interceptors.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration//为什么因为是配置类所有就要加什么东西
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    /*@Autowired是 Spring 框架中用于实现依赖注入（Dependency Injection，简称 DI）的关键注解。
    它的主要目的是让 Spring 容器自动识别并装配
    （注入）所需的依赖对象到目标对象中，
    从而简化对象之间的依赖关系管理，提高代码的可维护性和灵活性。*/
    private LoginInterceptor loginInterceptor;

    @Override//重写
    public void addInterceptors(InterceptorRegistry registry)
    {

        //登录接口和注册接口不拦截
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/user/login","/user/register");
    }
}
